After studying the relation of distributive function and density matrix , the electron energy is calculated in magnetic field according to the distributive function in the thermodynamic statistical physics and the density matrix average value principle in the quantum mechanics , respectively 摘要研究正则系综中的配分函数与密度矩阵的关系,分别采用热力学统计物理中的配分函数和量子力学中的密度矩阵与平均值原理,计算电子在磁场中的能量。